str1 = 'Hello world! This is a simple text analysis program. Hello again!'
str_list = str1.split(' ')

print("=== 文本分析结果 ===")
print(f'字符总数：{len(str1)}')
print(f'词语总数：{len(str_list)}')
print()

print(f'词语列表：\n{str_list} \n')

max_len = str_list[0]
min_len = str_list[0]
for word in str_list:
    if len(word) > len(max_len):
        max_len = word
    if len(word) < len(min_len):
        min_len = word

print(f'最长词语：{max_len}.({len(max_len)})个字符')
print(f'最短词语：{min_len}.({len(min_len)})个字符\n')

# 逗号统计
comma_count = 0
# 感叹号统计
exclamation_count = 0
# 句号统计
period_count = 0

for charactor in str1:
    if charactor == ',':
        comma_count += 1
    elif charactor == '!':
        exclamation_count += 1
    elif charactor == '.':
        period_count += 1
print(f'逗号数：{comma_count}')
print(f'感叹号数：{exclamation_count}')
print(f'句号数：{period_count}')
